package com.monee.springboot.bus.controller;


import com.monee.springboot.bus.entity.City;
import com.monee.springboot.bus.entity.Student;
import com.monee.springboot.bus.service.TestService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;

@Controller
@RequestMapping("/test")
public class IndexController {

    private TestService testService;

    @Autowired
    public void setTestService(TestService testService) {
        this.testService = testService;
    }

    @RequestMapping("/index")
    public String index(String name, Model model) {

        Student student = testService.test();
        model.addAttribute("student", student);
        model.addAttribute("name", name);

        return "index";
    }

    @RequestMapping("/cityList")
    public String cityList(String name, Model model) {

        List<City> cityList = testService.getCityList();
        model.addAttribute("cityList", cityList);

        return "cityList";
    }

}
